$(function(){
  
  let form = layui.form
  $('form').on('submit',function(e){
    e.preventDefault()
    // 获取form表单的值
    let fd = $(this).serialize()
    console.log(fd);

    $.ajax({
      type:'post',
      url:'api/login',
      data:fd,
      success:function(res){
        console.log(res);
        if(res.status === 0){
          localStorage.setItem('token',res.token)
          layer.msg(res.message)
          setTimeout(() => {
            location.href = './index.html'
          }, 1000);
          // location.href = '/admin/login.html'
        }
      }
    })
  })
})